package com.example.ms.cxgc;

/**
 * 抽象工厂
 */
public class abstractFactory {

    public static void main(String[] args) {
        Factory factory = new Approval_B();


        Approval approval = factory.getApproval();
        System.out.println(approval.toString());
        Approval approval2 = factory.getApproval2();
        System.out.println(approval2.toString());




    }


    interface Factory {
        /**
         * 发起审批
         */
        Approval getApproval();

        /**
         * 发起审批2
         */
        Approval getApproval2();
    }


    static class Approval_A implements Factory {
        @Override
        public Approval getApproval() {
            Approval approval = new Approval();
            approval.setApprovalId("A");
            approval.setApprovalName("AA");
            return approval;
        }

        @Override
        public Approval getApproval2() {
            Approval approval = new Approval();
            approval.setApprovalId("A_getApproval2");
            approval.setApprovalName("AA_getApproval2");
            return approval;
        }
    }

    static class Approval_B implements Factory {
        @Override
        public Approval getApproval() {
            Approval approval = new Approval();
            approval.setApprovalId("B");
            approval.setApprovalName("BB");
            return approval;
        }

        @Override
        public Approval getApproval2() {
            Approval approval = new Approval();
            approval.setApprovalId("BBB_getApproval2");
            approval.setApprovalName("BBB_getApproval2");
            return approval;
        }
    }


}
